﻿using System;

namespace YArchitech.HCLoad.XmlData
{
	public class Result
	{
		public double[] CoolingLoad
		{
			get
			{
				return this.m_arrZLFHAll;
			}
		}

		public double[] CoolingSensibleLoad
		{
			get
			{
				return this.m_arrZLFhXr;
			}
		}

		public double[] CoolingLatentLoad
		{
			get
			{
				return this.m_arrZLFhQr;
			}
		}

		public double[] CoolingHumidityLoad
		{
			get
			{
				return this.m_arrZSFh;
			}
		}

		public double HeatingLoad
		{
			get
			{
				return this.HeatingSensibleLoad + this.HeatingLatentLoad;
			}
		}

		public double HeatingSensibleLoad
		{
			get
			{
				return this.m_dDJRFHXr;
			}
			set
			{
				this.m_dDJRFHXr = value;
			}
		}

		public double HeatingLatentLoad
		{
			get
			{
				return this.m_dDJRFHQr;
			}
			set
			{
				this.m_dDJRFHQr = value;
			}
		}

		public double HeatingHumidityLoad
		{
			get
			{
				return this.m_dDJSFH;
			}
			set
			{
				this.m_dDJSFH = value;
			}
		}

		public double XJLFHMaxAll
		{
			get
			{
				return this.m_dXJLFHMaxAll;
			}
		}

		public double XJMaxSFH
		{
			get
			{
				return this.m_dXJMaxSFH;
			}
		}

		public int MaxValueTime
		{
			get
			{
				return this.m_nMaxTime;
			}
		}

		public Result()
		{
			this.m_arrZLFHAll = new double[24];
			this.m_arrZLFhQr = new double[24];
			this.m_arrZLFhXr = new double[24];
			this.m_arrZSFh = new double[24];
			this.m_dDJRFHXr = 0.0;
			this.m_dDJRFHQr = 0.0;
			this.m_dDJSFH = 0.0;
		}

		public static double[] Sum(double[] ary1, double[] ary2)
		{
			double[] array = new double[24];
			int num = 0;
			while (num < ary1.Length && num < ary2.Length)
			{
				array[num] = ary1[num] + ary2[num];
				num++;
			}
			return array;
		}

		public static double[] Subtract(double[] ary1, double[] ary2)
		{
			double[] array = new double[24];
			int num = 0;
			while (num < ary1.Length && num < ary2.Length)
			{
				array[num] = ary1[num] - ary2[num];
				num++;
			}
			return array;
		}

		public static double GetMaxValue(double[] aryDoubles)
		{
			double num = aryDoubles[0];
			foreach (double num2 in aryDoubles)
			{
				if (num2 > num)
				{
					num = num2;
				}
			}
			return num;
		}

		public static int GetMaxValueIndex(double[] aryDoubles)
		{
			int num = 0;
			for (int i = 1; i < aryDoubles.Length; i++)
			{
				if (aryDoubles[i] > aryDoubles[num])
				{
					num = i;
				}
			}
			return num;
		}

		public static bool Append(ref double[] aryResult, double[] aryToAppend)
		{
			int num = 0;
			while (num < aryResult.Length && num < aryToAppend.Length)
			{
				aryResult[num] += aryToAppend[num];
				num++;
			}
			return true;
		}

		public static bool Reduce(ref double[] aryResult, double[] aryToReduce)
		{
			int num = 0;
			while (num < aryResult.Length && num < aryToReduce.Length)
			{
				aryResult[num] -= aryToReduce[num];
				num++;
			}
			return true;
		}

		public static double[] Devide(double[] ary, double d)
		{
			double[] array = new double[ary.Length];
			for (int i = 0; i < ary.Length; i++)
			{
				if (Math.Abs(d) < 1E-05)
				{
					array[i] = 0.0;
				}
				else
				{
					array[i] = ary[i] / d;
				}
			}
			return array;
		}

		public Result Increase(Result data)
		{
			if (data != null)
			{
				Result.Append(ref this.m_arrZLFHAll, data.CoolingLoad);
				Result.Append(ref this.m_arrZLFhQr, data.CoolingSensibleLoad);
				Result.Append(ref this.m_arrZLFhXr, data.CoolingLatentLoad);
				Result.Append(ref this.m_arrZSFh, data.CoolingHumidityLoad);
				this.m_dDJRFHXr += data.HeatingSensibleLoad;
				this.m_dDJRFHQr += data.HeatingLatentLoad;
				this.m_dDJSFH += data.HeatingHumidityLoad;
			}
			return this;
		}

		public Result Decrease(Result data)
		{
			if (data != null)
			{
				Result.Reduce(ref this.m_arrZLFHAll, data.CoolingLoad);
				Result.Reduce(ref this.m_arrZLFhQr, data.CoolingSensibleLoad);
				Result.Reduce(ref this.m_arrZLFhXr, data.CoolingLatentLoad);
				Result.Reduce(ref this.m_arrZSFh, data.CoolingHumidityLoad);
				this.m_dDJRFHXr -= data.HeatingSensibleLoad;
				this.m_dDJRFHQr -= data.HeatingLatentLoad;
				this.m_dDJSFH -= data.HeatingHumidityLoad;
			}
			return this;
		}

		public static Result operator -(Result data1, Result data2)
		{
			new Result();
			data1.Decrease(data2);
			return data1;
		}

		public static Result operator +(Result data1, Result data2)
		{
			new Result();
			data1.Increase(data2);
			return data1;
		}

		public const int nTimeCount = 24;

		protected double[] m_arrZLFHAll;

		protected double[] m_arrZLFhXr;

		protected double[] m_arrZLFhQr;

		protected double[] m_arrZSFh;

		protected double m_dDJRFHXr;

		protected double m_dDJRFHQr;

		protected double m_dDJSFH;

		protected double m_dXJLFHMaxAll;

		protected double m_dXJMaxSFH;

		protected int m_nMaxTime;
	}
}
